
<?php
    class categoryComponents extends sfComponents
    {     
        
        public function executeMenufooter(sfWebRequest $request)
        {
           $this->categorys = Doctrine_core::getTable('BachkimCategory')->getParentcategory();
           
        }
       
       
       
        /*
        
        public function executeMenu(sfWebRequest $request)
        {
           $this->categorys = Doctrine_core::getTable('BachkimCategory')->getParentcategory();
           
        }
        
        public function executeMenufooter(sfWebRequest $request)
        {
           $this->categorys = Doctrine_core::getTable('BachkimCategory')->getParentcategory();
           
        }

        //         
        public function executeListall()
        {
             $this->categorys = Doctrine_core::getTable('BachkimCategory')->getParentcategory();
        }
        
        // gioi thieu cong ty
        public function executeIntroduce(sfWebRequest $request)
          {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory2('gioithieucongty');
            /*
             $this->cate = Doctrine_core::getTable('BachkimCategory')
                ->createQuery()
                ->Where('code=?', 'gioithieucongty')
                ->execute();
               
           }
           
        // danh sach bai viet trong category: tin tuc   
       public function executeNewartice(sfWebRequest $request)
          {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory2('tintuc');  
             
            foreach($this->cate as $category):;
                // phan trang
                    $this->pager = new sfDoctrinePager(
                        'BachkimArtice',
                        sfConfig::get('app_max_artices_on_category')
                      );
                    $this->pager->setQuery($category->getWithArticeQuery());
                    $this->pager->setPage($request->getParameter('page', 1));
                    $this->pager->init();
            endforeach;          
           } 
           
        // danh sach bai viet trong category: thong bao   
       public function executeNotice(sfWebRequest $request)
          {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory2('thongbao');
             
             foreach($this->cate as $category):;
                // phan trang
                    $this->pager = new sfDoctrinePager(
                        'BachkimArtice',
                        sfConfig::get('app_max_artices_on_category')
                      );
                    $this->pager->setQuery($category->getWithArticeQuery());
                    $this->pager->setPage($request->getParameter('page', 1));
                    $this->pager->init();
            endforeach;  
                 
           }  
            
        // tai nguyen
        public function executeResource(sfWebRequest $request)
           {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory1('tainguyen',0);
             foreach($this->cate as $category):;
                echo "<h1>".$category->getTitle()."</h1>";
                // phan trang
                    $this->pager = new sfDoctrinePager(
                        'BachkimArtice',
                        sfConfig::get('app_max_artices_on_category')
                      );
                    $this->pager->setQuery($category->getSubcategoryQuery());
                    $this->pager->setPage($request->getParameter('page', 1));
                    $this->pager->init();
            endforeach;
             
           }
            
        // san pham
        public function executeProduct(sfWebRequest $request)
          {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory1('sanpham',0);
             foreach($this->cate as $category):;
                echo "<div class='product'><h2>".$category->getTitle()."</h2> <p class='viewall'><a href=''> Tất cả</a> </p>";
                // phan trang
                    $this->pager = new sfDoctrinePager(
                        'BachkimArtice',
                        sfConfig::get('max_product: 4')
                      );
                    $this->pager->setQuery($category->getSubcategoryQuery());
                    $this->pager->setPage($request->getParameter('page', 1));
                    $this->pager->init();
                echo "</div>";
            endforeach;    
            
           } 
           
        // dich vu   
        public function executeService(sfWebRequest $request)
          {
             $this->cate = Doctrine_core::getTable('BachkimCategory')->getCategory1('dichvu',0);
             foreach($this->cate as $category):;
                echo "<h1>".$category->getTitle()."</h1>";
                // phan trang
                    $this->pager = new sfDoctrinePager(
                        'BachkimArtice',
                        sfConfig::get('app_max_artices_on_category')
                      );
                    $this->pager->setQuery($category->getSubcategoryQuery());
                    $this->pager->setPage($request->getParameter('page', 1));
                    $this->pager->init();
            endforeach;
           } 
           
           */ 
    } 
?>   
        
        
        
                     
